<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script src="//cdn.bootcss.com/sockjs-client/1.1.2/sockjs.js"></script>
	<script type="text/javascript">
		var url = 'marco';
		var ws = new SockJS(url);
		
		ws.onopen = function(){
			console.log('Opening');
			sayMarco();
		}
		
		ws.onmessage = function(e){
			console.log('Received message: ' + e.data);
			setTimeout(function(){
				sayMarco(),2000
			});
		}
		
		ws.onclose = function(){
			console.log('Closing');
		}
		
		ws.onerror = function(e){
			console.log(e)
		}
		
		function sayMarco(){
			console.log('Sending Marco');
			ws.send("Marco!");
		}
	</script>
</body>
</html>